export const performChunk = (datas: any[], comsumer: (data: any) => void) => {
  if (typeof datas === 'number') {
    datas = new Array(datas)
  }
  if (datas.length === 0) return
  let i = 0
  const _run = () => {
    if (i === datas.length) return
    requestIdleCallback((deadline: any) => {
      while (deadline.timeRemaining() > 0 && i < datas.length) {
        comsumer(datas[i])
        i++
      }
      _run()
    })
  }
  _run()
}
